<?php
	
/**
 * Project: CrazyPoems
 * Author: Alexandru
 * Date: 20/10/2008
 * File: functions.member.php
 */
 
function Hop_getUserPoems($username) {
    $userPoems = array();
	$q = mysql_query("SELECT id, title FROM ".TABLE_POEMS." WHERE author = '$username' ORDER BY id") or die(mysql_error());
    if (mysql_num_rows($q) > 0) {
        while ($r = mysql_fetch_assoc($q)) {
            $tmp = array('id' => $r['id'], 'title' => $r['title'], 'link' => get_link('poem', array('id' => $r['id'], 'title' => $r['title'], 'category' => $r['category'])));
            $userPoems[] = $tmp;
        }
        return $userPoems;
    } else {
	    return "";
    }
}

function Hop_countUserPoems($username) {
    $c = "SELECT count(id) AS total FROM ".TABLE_POEMS." WHERE author = '$username'";
	$q = mysql_query($c) or die(mysql_error());
	$r = mysql_fetch_assoc($q);
	if ($r) {
		return $r['total'];
	} else {
		return 0;
	}
}

function Hop_getUserPhoto($filename) {
	if (strlen($filename) > 0 && file_exists(USER_PHOTO_PATH."$filename")) {
		return "images_members/$filename";
	} else {
		return "";
	}
}
 
?>
